<template>
	<el-popover
		v-model="showPopover"
		width="360"
		trigger="manual"
		icon="el-icon-info"
		title="提示"
	>
		<div>
			<div>将根据"自动排班规则"触发一次自动排班;</div>
		</div>
		<div class="flex-end-center margin-top-10">
			<el-button size="small" @click="showPopover = false">取消</el-button>
			<el-button :loading="confirmBtnLoading" size="small" type="primary" @click="onConfirmBtn">确定</el-button>
		</div>
		<el-button slot="reference" :size="size" icon="el-icon-cpu" class="current-month" @click="showPopover = true">触发一次自动排班</el-button>
	</el-popover>
</template>
<script>
    import {
        workforceManagementScheduleAutoCopySchedule
    } from '../../../../api/schedule/scheduling';
    import { tipsBar } from '../../../../utils/jk/jk-tool';

    export default {
        props: {
            workshopId: {
                type: [String, Number],
                default: ''
            },
            size: {
                type: String,
                default: ''
            },
            checkData: {
                type: Object,
                default() {
                    return {};
                }
            }
        },
        data() {
            return {
                confirmBtnLoading: false,
                showPopover: false
            };
        },
        methods: {
            onConfirmBtn() {
                this.confirmBtnLoading = true;
                workforceManagementScheduleAutoCopySchedule({
                    workshopId: this.workshopId
                }).then(res => {
                    this.confirmBtnLoading = false;
                    if (res.data.status === 200) {
                        this.showPopover = false;
                        tipsBar(this, 'save');
                        this.$emit('on-confirm');
                    }
                });
            }
        }
    };
</script>
